package ksu_product.proGen.util;

import java.util.ArrayList;
import java.util.List;

import ksu_product.proGen.dto.TableDTO;
import ksu_product.proGen.dto.TemplateDTO;

import net.sf.json.JSONArray;

import org.apache.commons.lang.StringUtils;


public class SystemConfig {

	public static String NO_PREFIX;

	public static String TEMPLATE_PATH;
	
	public static String FILE_OUTPUT_PATH;
	
	public static String TEMPLATE_LIST;
	
	public static String TABLE_LIST;

	public static void setTEMPLATE_PATH(String tEMPLATE_PATH) {
		TEMPLATE_PATH = tEMPLATE_PATH;
	}
	
	public static void setFILE_OUTPUT_PATH(String fILE_OUTPUT_PATH) {
		FILE_OUTPUT_PATH = fILE_OUTPUT_PATH;
	}
	
	public static void setTEMPLATE_LIST(String tEMPLATE_LIST){
		TEMPLATE_LIST = tEMPLATE_LIST;
	}
	
	public static void setNO_PREFIX(String nO_PREFIX){
		NO_PREFIX = nO_PREFIX;
	}
	
	@SuppressWarnings({ "unchecked", "static-access", "deprecation" })
	public static List<TemplateDTO> getTemplateList(){
		if(StringUtils.isNotBlank(TEMPLATE_LIST)){
			List<TemplateDTO> templateList = new ArrayList<TemplateDTO>();
			JSONArray jsonArray = JSONArray.fromObject(TEMPLATE_LIST);
			templateList.addAll(jsonArray.toList(jsonArray, TemplateDTO.class));
			return templateList;
		}
		return null;
	}
	
	public static void setTABLE_LIST(String tABLE_LIST){
		TABLE_LIST = tABLE_LIST;
 	}
	
	@SuppressWarnings({ "unchecked", "static-access", "deprecation" })
	public static List<TableDTO> getTableList(){
		if(StringUtils.isNotBlank(TABLE_LIST)){
			List<TableDTO> tableList = new ArrayList<TableDTO>();
			JSONArray jsonArray = JSONArray.fromObject(TABLE_LIST);
			tableList.addAll(jsonArray.toList(jsonArray, TableDTO.class));
			return tableList;
		}
		return null;
	}
	
}
